Fix timing issue in parallel execution#4629
Merged
nohwnd merged 4 commits intomicrosoft:mainfrom Aug 2, 2023
Merged
Conversation
Member
Author
|
/azp run |
|
No commit pushedDate could be found for PR 4629 in repo microsoft/vstest |
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
nohwnd
commented
Aug 2, 2023
| // This must be set last, every loop below looks at this property, | ||
| // and they can do so from a different thread. So if we mark it as HasWork before actually assigning the work | ||
| // we can pick up the slot, but it has no associated work yet. | ||
| slot.HasWork = true; |
Evangelink
approved these changes
Aug 2, 2023
Member
Evangelink
left a comment
There was a problem hiding this comment.
Linking #4630 here to explain why we approve the change as-is.
nohwnd
added a commit
to nohwnd/vstest
that referenced
this pull request
Aug 2, 2023
Merged
nohwnd
added a commit
that referenced
this pull request
Aug 2, 2023
Co-authored-by: Amaury Levé <amauryleve@microsoft.com> Fix timing issue in parallel execution (#4629)
This was referenced Jul 22, 2025
Merged
This was referenced Feb 5, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Parallel workers are able to pick up work between setting HasWork and actually associating the workload, which leads to the work being unscheduled. The test run (or test discovery) then never finishes. This was observed on a run with 99 dlls, and can be reproduced locally. To me it was on parallel runs of 12 hosts.
This fix moves HasWork to be the last item to be set under the lock, so the readers that are outside of the lock cannot read it too early before the slot is completely populated.